<?php

Yii::import('application.models._base.BaseSalestransDetails');
class SalestransDetails extends BaseSalestransDetails
{
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
    public function save_beauty_tips()
    {
        if ($this->beauty_id != null) {
            $price = Price::get_price($this->barang_id, $this->beauty->gol_id);
            if ($price == null)
                throw new Exception("Tips value not define");
            $total_tips = $this->qty * $price->value;
            $this->beauty_tip = $total_tips;
        } else {
            $this->beauty_tip = 0;
        }
        if (!$this->save()) {
            throw new Exception("Save tips failed. " . CHtml::errorSummary($this));
        }
    }
}